<?php
/**
 * Created by PhpStorm.
 * User: sakura
 * Date: 2019/5/6
 * Time: 11:52 AM
 */

namespace app\common\model;

use think\Route;

class Orders extends Model
{
    protected $name = 'order';

    public function users(){
        return $this->belongsTo('users','user_id','id');
    }

    public function driver(){
        return $this->belongsTo('driver','dr_id','id');
    }

    public function car(){
        return $this->belongsTo('car','car_id','id');
    }
    protected function getAdminStatusTextAttr($vaule, $data)
    {
        $text = [
            0 => '未结算',
            1 => '已结算'
        ];
        return $text[$data['status']];
    }

    protected function getUpdateTimeAttr($value)
    {
        return $value>0?date('Y-m-d H:i:s',$value):'/';
    }


    protected function getCreateTimeAttr($value)
    {
        return $value>0?date('Y-m-d H:i:s',$value):'/';
    }

    protected function getEndTimeAttr($value)
    {
        return $value>0?date('Y-m-d H:i:s',$value):'/';
    }
}